package com.rd.student.jike.class2.lihongming.week724_730.Day725;

import java.io.File;
import java.io.IOException;

/**
 * @Auther:Heinrich
 * @Date:2023/7/25-07-25-10:46
 * @Description:com.rd.student.jike.class2.lihongming.Day0725
 * @version:1.0
 */
public class TestFile {


    public static void main(String[] args) {
        System.out.println(System.getProperty("user.dir"));
        String path = "C:\\Users\\30578\\Desktop";
        File file = new File(path);
        System.out.println(file.isFile());
        System.out.println(file.isDirectory());
        File dir = new File(file+"\\"+"1.txt");


        System.out.println(file.canRead());
        System.out.println(file.canWrite());
        System.out.println(file.canExecute());

        File newFile = new File(file+"\\"+"2.txt");
        try {
            boolean result = newFile.createNewFile();
            if(result){
                System.out.println("创建成功");
                System.out.println(newFile);
            }else{
                System.out.println("创建失败");
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        int i=0;
        File profile = new File(file+"\\"+"3");
        while (i==1) {
            boolean result = profile.mkdir();
            if (result) {
                System.out.println("创建成功");
                //System.out.println(newFile);
            } else {
                System.out.println("创建失败");
            }
            boolean result1 = profile.delete();
            if (result1) {
                System.out.println("删除成功");
                //System.out.println(newFile);
            } else {
                System.out.println("删除失败");
            }
        }
        //重命名
        newFile.renameTo(new File(file + "\\" + "3.txt"));
    }
}
